﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;


namespace Handrise.CDCable.Mobile.UI
{

    public class SYSTEM_POWER_STATUS_EX
    {
        public byte ACLineStatus;
        public byte BatteryFlag;
        public byte BatteryLifePercent;
        public byte Reserved1;
        public uint BatteryLifeTime;
        public uint BatteryFullLifeTime;
        public byte Reserved2;
        public byte BackupBatteryFlag;
        public byte BackupBatteryLifePercent;
        public byte Reserved3;
        public uint BackupBatteryLifeTime;
        public uint BackupBatteryFullLifeTime;
    }


    class CElectricQuantity
    {
    
        [DllImport("coredll")]
        private static extern uint GetSystemPowerStatusEx(SYSTEM_POWER_STATUS_EX lpSystemPowerStatus,
            bool fUpdate);
        public static int getBatterysize()
        {

            SYSTEM_POWER_STATUS_EX status = new SYSTEM_POWER_STATUS_EX();


            if (GetSystemPowerStatusEx(status, false) == 1)
            {
                return (int)status.BatteryLifePercent;
            }
            else
                return -1;
        }
    }





    }
